package com.qf.java2201.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.java2201.common.PageVo;
import com.qf.java2201.mapper.BackMapper;
import com.qf.java2201.pojo.Back;
import com.qf.java2201.service.BackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author yjl
 * @version 1.0
 * @date 2022/4/26 14:32
 */
@Service("backService")
public class BackServiceImpl implements BackService {
    @Autowired
    private BackMapper backMapper;

    @Override
    public PageVo<Back> getPageData(Map<String, Object> params, Back back) {

        String page = (String) params.get("page");
        String limit = (String) params.get("limit");

        PageHelper.startPage(Integer.parseInt(page),Integer.parseInt(limit));

        List<Back> backs = backMapper.selectByParams(params,back);

        PageInfo<Back> backPageInfo = new PageInfo<>(backs);

        PageVo<Back> backPageVo = new PageVo<>();

        backPageVo.setData(backPageInfo.getList());
        backPageVo.setCode(0);
        backPageVo.setCount(backPageInfo.getTotal());
        backPageVo.setMsg("用户反馈数据");
        return backPageVo;

    }

    @Override
    public int addback(Back back) {
        return backMapper.addBack(back);
    }

    @Override
    public int deleteBackById(Back back) {
        return backMapper.deleteBackById(back);
    }

    @Override
    public int updateBack(Back back) {
        return backMapper.updateBack(back);
    }

    @Override
    public void addExcele(List<Back> backs) {
        //批量添加
        backMapper.addExcele(backs);
    }

    @Override
    public List<Back> backList(Back back) {
        return backMapper.backList(back);
    }

}
